
//Base on a script by Paul McFedries 
var DSLsecs
var DSLtimerID = null
var DSLtimerRunning = false
var DSLdelay = 1000
var DSLmintime = 60
var DSLMessage = '1 minute remaining!!!'
var DSLAction=1
var DSLObject=null
var DSLActionExecuted = 0
var DSLTimeOutText='Session timeout!!!'

function DSLInitializeTimer(pAction,pSecs,pMin,pMessage,pTimeoutText)
{
    DSLAction = pAction
    DSLsecs = pSecs
    DSLmintime = pMin
    DSLMessage = pMessage
    DSLTimeOutText = pTimeoutText
    DSLObject=document.getElementById('DSLSessionTimeOutCounter')
		if(DSLObject) DSLObject.innerText=''
    DSLStopTheClock()
    DSLStartTheTimer()
}

function DSLStopTheClock()
{
    if(DSLtimerRunning)
        clearTimeout(DSLtimerID)
    DSLtimerRunning = false
}

function DSLStartTheTimer()
{
    if (DSLsecs<=DSLmintime && DSLsecs>0 && DSLActionExecuted==0)
    {
        DSLActionExecuted=1
        DSLDoStep()
        switch(DSLAction){
			case 1: self.setTimeout("alert(DSLMessage)",1)
					break
			case 2: self.setTimeout("if(confirm(DSLMessage)) __doPostBack('DSNocontrol','')",1)
					break
			case 3: DSLStopTheClock()
					__doPostBack('DSNocontrol','')
					break
			default:
					DSLStopTheClock()
					DSLObject=document.getElementById('DSLSessionTimeOutCounter')
					if(DSLObject) DSLObject.innerText='Error!!!'
		}
    }
    else if (DSLsecs<=0){
		DSLStopTheClock()
		DSLObject=document.getElementById('DSLSessionTimeOutCounter')
		if(DSLObject) DSLObject.innerText=DSLTimeOutText
    }
    else
    {
		DSLDoStep()
    }
}

function DSLDoStep()
{
		DSLObject=document.getElementById('DSLSessionTimeOutCounter')
		if(DSLObject) DSLObject.innerText=DSLCheckTime(Math.floor(DSLsecs/60))+':'+DSLCheckTime(DSLsecs % 60)
	    DSLsecs = DSLsecs - 1
        DSLtimerRunning = true
        DSLtimerID = self.setTimeout("DSLStartTheTimer()", DSLdelay)
}

function DSLCheckTime(i)
{
if (i<10) 
  {i="0" + i}
  return i
}


